package com.leftheart.entity;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.leftheart.utils.DateUtils;
import com.leftheart.utils.Utils;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

@Data
@NoArgsConstructor
public class Rental {

    private long rentalId;
    private String rentalName;
    private int rentalUserId;
    private String rentalUserName;
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd hh:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd hh:mm:ss")
    private String rentalDate;
    private String rentalComment;

    public long getRentalId() {
        return rentalId;
    }

    public void setRentalId() {
        this.rentalId = Utils.setRentalId();
    }

    public String getRentalDate() {
        return rentalDate;
    }

    public void setRentalDate() {
        this.rentalDate = DateUtils.jsonDate(new Date());
    }

    public Rental(int rentalId, String rentalName, int rentalUserId, String rentalUserName, String rentalComment, Date rentalDate) throws JsonProcessingException {
        Date date = new Date();
        this.rentalId = rentalId;
        this.rentalName = rentalName;
        this.rentalUserId = rentalUserId;
        this.rentalUserName = rentalUserName;
        this.rentalComment = rentalComment;
        this.rentalDate = DateUtils.jsonDate(date);
    }
}
